# encoding:utf-8
# driver的常用操作
import time

from selenium.webdriver.common.by import By

from utils.webdriver_factory import WebDriverFactory

driver = WebDriverFactory.get_instance()

# 操作Element对象

driver.get("http://www.baidu.com")
# 单击
driver.find_element(*(By.ID, "su")).click()
time.sleep(2)
# 输入内容
driver.find_element(By.ID, "kw").send_keys("selenium")
time.sleep(2)
# 清空输入框
driver.find_element(By.ID, "kw").clear()

# Driver的常用操作
# 后退
driver.back()
time.sleep(3)
# 前进
driver.forward()
time.sleep(3)
# 刷新
driver.refresh()
time.sleep(2)
# 关闭当前窗口
driver.close()
time.sleep(3)
# 关闭浏览器
driver.quit()
